<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
    <meta http-equiv="expires" content="0">
    <title>我的记录</title>
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="css/index.css">
</head>
<body>
<div style="padding-top: 10px;font-size: 12px;">
    <ul class="nav nav-tabs nav-justified">
        <li role="presentation" class="mine-all active"><a class="head-tab" id="all">全部</a></li>
        <li role="presentation" class="mine-before"><a class="head-tab" id="before">等待开奖</a></li>
        <li role="presentation" class="mine-win"><a class="head-tab" id="win">已中奖</a></li>
        <li role="presentation" class="mine-lose"><a class="head-tab" id="lose">未中奖</a></li>
    </ul>
</div>
<div class="tab">
    <div id="mine-tab">
        <ul>
<!--            <li>-->
<!--                <div class="act_div">-->
<!--                    <div>-->
<!--                        <img src="img/tmp/首页商品.png" alt="">-->
<!--                    </div>-->
<!--                    <div class="act_detail">-->
<!--                        <p><span>第C19期</span><span>8月30日开奖</span></p>-->
<!--                        <span></span>-->
<!--                        <p>iPhone6s黑色黑色黑色黑色黑色黑色黑色</p>-->
<!--                        <p><span>市场价:4990.00元</span><span>数量：1</span></p>-->
<!--                    </div>-->
<!--                </div>-->
<!--                <i style="display: none;"></i>-->
<!--            </li>-->
        </ul>
    </div>
</div>
<script src="js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script src="js/sha1.js"></script>
<script src="js/config.js"></script>
<script src="js/public2.js"></script>
<script type="text/javascript">
    let data = [];
    let activeName = 'all';
    function afterVerify() {
        //加载接口
        $.post(baseUrl+'client/mine',{},function(result){
            if(result.code === 0){
                data = result.data;
                let html = fillHtml();
                $('#mine-tab>ul').html(html);
            }else{
                alert(result.msg);
            }
        },'json');

    }
    function fillHtml(type = 'all'){
        let html = '';
        switch(type){
            case 'all':
                if(data.length === 0){
                    return '<li>暂无数据</li>';
                }
                for(let i = 0; i<data.length; i++){
                    html += '<li><div class="act_div">';
                    html += '<div><img src="'+ data[i].goods_imgs[0] +'" alt=""></div>';
                    html += '<div class="act_detail">';
                    html += '<p><span>第'+ data[i].act_no +'期</span><span>'+ data[i].draw_time +'开奖</span></p>';
                    html += '<span></span>';
                    html +=  '<p>'+ data[i].goods_name +'</p>';
                    html += '<p><span>市场价:'+ data[i].price +'</span><span>奖品数量：'+ data[i].number +'</span></p>';
                    html +=  '</div></div><i style="display: none;">' + data[i].act_id + '</i></li>';
                }
                break;
            case 'before':
                for(let i = 0;i<data.length; i++){
                    if(data[i].status !== 2){
                        html += '<li><div class="act_div">';
                        html += '<div><img src="'+ data[i].goods_imgs[0] +'" alt=""></div>';
                        html += '<div class="act_detail">';
                        html += '<p><span>第'+ data[i].act_no +'期</span><span>'+ data[i].draw_time +'开奖</span></p>';
                        html += '<span></span>';
                        html +=  '<p>'+ data[i].goods_name +'</p>';
                        html += '<p><span>市场价:'+ data[i].price +'</span><span>奖品数量：'+ data[i].number +'</span></p>';
                        html +=  '</div></div><i style="display: none;">' + data[i].act_id + '</i></li>';
                    }
                }
                if(html === '') return '<li>暂无数据</li>';
                break;
            case 'win':
                for(let i = 0;i<data.length; i++){
                    if(data[i].status === 2 && data[i].win){
                        html += '<li><div class="act_div">';
                        html += '<div><img src="'+ data[i].goods_imgs[0] +'" alt=""></div>';
                        html += '<div class="act_detail">';
                        html += '<p><span>第'+ data[i].act_no +'期</span><span>'+ data[i].draw_time +'开奖</span></p>';
                        html += '<span></span>';
                        html +=  '<p>'+ data[i].goods_name +'</p>';
                        html += '<p><span>市场价:'+ data[i].price +'</span><span>'+ data[i].number +'人中奖(' + (data[i].received?'已领取':(data[i].expired?'已过期':'待领取')) + ')</span></p>';
                        html +=  '</div></div><i style="display: none;">' + data[i].act_id + '</i></li>';
                    }
                }
                if(html === '') return '<li>暂无数据</li>';
                break;
            case 'lose':
                for(let i = 0;i<data.length; i++){
                    if(data[i].status === 2 && !data[i].win){
                        html += '<li><div class="act_div">';
                        html += '<div><img src="'+ data[i].goods_imgs[0] +'" alt=""></div>';
                        html += '<div class="act_detail">';
                        html += '<p><span>第'+ data[i].act_no +'期</span><span>'+ data[i].draw_time +'开奖</span></p>';
                        html += '<span></span>';
                        html +=  '<p>'+ data[i].goods_name +'</p>';
                        html += '<p><span>市场价:'+ data[i].price +'</span><span>'+ data[i].number +'人中奖</span></p>';
                        html +=  '</div></div><i style="display: none;">' + data[i].act_id + '</i></li>';
                    }
                }
                if(html === '') return '<li>暂无数据</li>';
                break;
            default:
                return '<li>暂无数据</li>';
        }
        return html;
    }

    $('.head-tab').click(function(){
        activeName = $(this).attr('id');
        $('.head-tab').parent().removeClass('active');
        $('#'+activeName).parent().addClass('active');
        let html = fillHtml(activeName);
        $('#mine-tab>ul').html(html);
    });

    $('#mine-tab').on("click",'li',function(){
        if($('#mine-tab>ul').html() === '<li>暂无数据</li>'){
            return;
        }
        let act_id = $(this).find('i').html();
        location.href = './detail.html?act_id='+act_id;
    });


    $('.index-btn').click(function(){
        location.href = './address.html';
    });


</script>
<script src="js/verify.js"></script>
</body>
</html>
